//
//  NSAttributedString+GJHighLight.m
//  GanJie
//
//  Created by edz on 2018/4/2.
//  Copyright © 2018年 GanJie. All rights reserved.
//

#import "NSAttributedString+GJHighLight.h"

@implementation NSAttributedString (GJHighLight)

/**
 高亮文字
 
 @param keyword 要高亮的字
 @param str 全部文字
 @param highLightColor 高亮颜色
 @return  返回结果
 */
+ (NSAttributedString *)highlightText:(NSString *)keyword inStr:(NSString *)str withHighColor:(UIColor *)highLightColor {
    NSRange range = [str rangeOfString:keyword];
    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithString:str];
    if (range.length > 0) {
        [attrStr addAttribute:NSForegroundColorAttributeName value:highLightColor range:range];
    } else {
        
    }
    return [[NSAttributedString alloc]initWithAttributedString:attrStr];
}





@end
